package com.fishery.customization.service.impl;

import com.fishery.customization.dao.ThemeDao;
import com.fishery.customization.entity.Page;
import com.fishery.customization.entity.Theme;
import com.fishery.customization.service.ThemeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ThemeServiceImpl implements ThemeService {

	@Autowired
	private ThemeDao themeDao;

	@Override
	public List<Theme> getAllThemes() {
		return themeDao.findAll();
	}

	@Override
	public boolean removeThemeById(String id) {
		return themeDao.deleteById(id) > 0;
	}

	@Override
	public boolean saveTheme(Theme theme) {
		return themeDao.insert(theme) > 0;
	}

	@Override
	public boolean saveThemeWithBatch(List<Theme> themes) {
		return themeDao.insertAll(themes) > 0;
	}

	@Override
	public boolean updateThemeById(Theme theme) {
		return themeDao.updateById(theme) > 0;
	}

	@Override
	public boolean removeThemeWithBatch(List<String> ids) {
		return themeDao.deleteAll(ids) > 0;
	}

	@Override
	public Page<Theme> pageAllThemes(int current, int size) {
		return themeDao.findAllWithPage(current, size);
	}

	@Override
	public Theme getThemeById(String id) {
		return themeDao.findById(id);
	}
}
